#include "SemanticNodeBlockGoto.h"

#include "main2.h"

/**
 *  @fn	SemanticNodeBlockGoto::SemanticNodeBlockGoto(const SyntaxTreeNode *gotoNodeParent,
 *  	SemanticNode *parent)
 * 
 *  @brief	Constructor. 
 * 
 *  @author	Nikola Novak
 *  @date	6/26/2009
 * 
 *  @param	gotoNodeParent	If non-null, the goto node parent.
 *  @param	parent			If non-null, the parent.
 */
SemanticNodeBlockGoto::SemanticNodeBlockGoto(const SyntaxTreeNode *gotoNodeParent, SemanticNode *parent) : SemanticNode(parent), LabeledNode(gotoNodeParent->Nodes->GetData(0)) {
	const SyntaxTreeNode *theNode = gotoNodeParent->Nodes->GetData(1)->Nodes->GetData(0);
	name = flattenNamePeriodAdd(*theNode->Nodes->GetData(1));
}

/**
 *  @fn	std::string SemanticNodeBlockGoto::toDebugString(int tab)
 * 
 *  @brief	Converts a tab to a debug string. 
 * 
 *  @author	Nikola Novak
 *  @date	6/25/2009
 * 
 *  @param	tab	The tab.
 * 
 *  @return	This object as a std::string.
 */
std::string SemanticNodeBlockGoto::toDebugString(int tab) {
	std::ostringstream res;
	for (int i = 0; i < tab; i++) res << DEBUG_STRING_RAZMAK;
	res << getLabelsDebugString() << ": goto " << name << std::endl;
	return res.str();
}
